package com.example.zwgt.yrfk.ui.main.fragment;

import android.content.Intent;
import android.os.Handler;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.example.zwgt.yrfk.R;
import com.example.zwgt.yrfk.base.mvpbase.BasePresenter;
import com.example.zwgt.yrfk.base.mvpbase.baseImpl.BaseFragment;
import com.example.zwgt.yrfk.ui.risk.activity.SelectIndexActivity;
import com.example.zwgt.yrfk.ui.risk.adapter.RiskAdapter;

import java.util.ArrayList;
import java.util.List;


import butterknife.BindView;


public class RiskFragment extends BaseFragment {

   private RiskAdapter adapter;
   private List<String> data=new ArrayList<>();
    @BindView(R.id.risk_list)
    RecyclerView riskList;


    @Override
    protected int getLayoutResource() {
        return R.layout.fragment_risk;
    }

    @Override
    protected void initView() {
        for(int i=1;i<=30;i++){
            data.add("模型"+i+"号");
        }
        riskList.setLayoutManager(new LinearLayoutManager(getContext()));
        adapter=new RiskAdapter(R.layout.layout_risk_item,data);
        adapter.openLoadAnimation(BaseQuickAdapter.ALPHAIN);
        riskList.setAdapter(adapter);
        adapter.setOnItemClickListener((adapter, view, position) -> {
          startActivity(new Intent(getContext(), SelectIndexActivity.class));
        });
        adapter.setOnLoadMoreListener(() -> {
          new Handler().postAtTime(new Runnable() {
              @Override
              public void run() {
                  adapter.setEnableLoadMore(false);
              }
          },3000);
        });

    }

    @Override
    public BasePresenter initPresenter() {
        return null;
    }


    @Override
    public void onDestroyView() {
        super.onDestroyView();
    }
}
